<%@ page import="ro.xblue.translator.LanguageBean,
                 ro.xblue.translator.TranslatorUtils,
                 ro.gateway.aida.fnd.FundingType,
                 ro.gateway.aida.fnd.FundingItem,
                 java.text.NumberFormat,
			  ro.gateway.aida.utils.*,
			  java.text.SimpleDateFormat,
              ro.gateway.aida.admin.ActivityObjectsOptions,
              ro.gateway.aida.admin.ActObjsOptsConst,
			  java.util.Date,
			  ro.gateway.aida.admin.PropertyListItem"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/translator.tld" prefix="trans" %>
<%LanguageBean lang_bean = TranslatorUtils.getCurrentLanguage(request, application);%>
<%FundingItem item = ( FundingItem ) request.getAttribute("funding_item");%>
<%NumberFormat nf = NumberFormat.getInstance(lang_bean.locale);%>
<%       ActivityObjectsOptions aoo = ActivityObjectsOptions.getInstance(); %>
<trans:initPage module="fundedit" />
<logic:present name="funding_item">
      <table width="100%" border="0" cellpadding="3" class=text_search bgcolor="f9f9f9" cellspacing="1">

      <!-- funding persons involved -->
<%--      <logic:present property="persons" name="funding_item">--%>
<%--      <tr>--%>
<%--            <td valign="top" bgcolor="#FFFFFF">--%>
<%--            <trans:showPageMessage label="fundedit.persinv" />:--%>
<%--            </td>--%>
<%--            <td bgcolor="#FFFFFF">--%>
<%--                  <logic:iterate id="person" name="funding_item" property="persons">--%>
<%--                        &middot;&nbsp;&nbsp;&nbsp;<bean:write name="person" property="fullName"  /><br>--%>
<%--                  </logic:iterate>--%>
<%--            </td>--%>
<%--      </tr>--%>
<%----%>
<%--      <tr>--%>
<%--            <td colspan="2" bgcolor="#FFFFFF">&nbsp;--%>
<%--            --%>
<%--            </td>--%>
<%--      </tr>--%>
<%--      </logic:present>--%>

      <!-- funding type -->
<%--      <logic:present name="funding_item" property="type">--%>
<%--      <bean:define id="type" name="funding_item" property="type" />--%>
<%--      <tr>--%>
<%--            <td bgcolor="#FFFFFF">--%>
<%--            <trans:showPageMessage label="fundedit.fundingtype" />:--%>
<%--            </td>--%>
<%--            <td bgcolor="#FFFFFF">--%>
<%--            <%=((FundingType)pageContext.getAttribute("type")).getName(lang_bean.language)%>--%>
<%--            </td>--%>
<%--      </tr>--%>
<%--      </logic:present>--%>

      <!-- type of assistance -->
    <% if (aoo.isEnabled(ActObjsOptsConst.FUNDING_TYPESASSIST)) { %>
      <logic:present name="funding_item" property="type_of_assistance">
      <bean:define id="type_of_assistance" name="funding_item" property="type_of_assistance" type="ro.gateway.aida.admin.PropertyListItem"/>
      <tr>
            <td bgcolor="#FFFFFF">
           <trans:showPageMessage label="fundedit.typeassist" />:
            </td>
            <td bgcolor="#FFFFFF">
		  <%=type_of_assistance.getString(lang_bean.language)%>
            </td>
      </tr>
      </logic:present>
    <% } %>

      <!-- funding status -->
      <% if (aoo.isEnabled(ActObjsOptsConst.FUNDING_STATUS)) { %>
      <logic:present name="funding_item" property="status">
      <bean:define id="status" name="funding_item" property="status" />
      <tr>
            <td bgcolor="#FFFFFF">
           <trans:showPageMessage label="fundedit.fundingstatus" />:
            </td>
            <td bgcolor="#FFFFFF">
            <%=((PropertyListItem)pageContext.getAttribute("status")).getString(lang_bean.language)%>
            </td>
      </tr>
      </logic:present>
      <% } %>

      <!-- terms of assistance -->
      <logic:present name="funding_item" property="terms_of_assistance">
      <bean:define id="terms_of_assistance" name="funding_item" property="terms_of_assistance" type="ro.gateway.aida.admin.PropertyListItem"/>
      <tr>
            <td bgcolor="#FFFFFF">
           <trans:showPageMessage label="fundedit.termsassist" />:
            </td>
            <td bgcolor="#FFFFFF">
		  <%=terms_of_assistance.getString(lang_bean.language)%>
            </td>
      </tr>
      </logic:present>

      <!-- funding amount -->
      <tr>
            <td bgcolor="#FFFFFF">
            <trans:showPageMessage label="fundedit.amount" />:
            </td>
            <td bgcolor="#FFFFFF">
            <%=nf.format(item.getAmount())%>
            <trans:showPageMessage label="fundedit.currency" />:
            <bean:write name="funding_item" property="currency" />
            </td>
      </tr>

	 <%SimpleDateFormat date_formatter = new SimpleDateFormat("dd/MM/yyyy");%>
	 <!-- signature date -->
     <% if (aoo.isEnabled(ActObjsOptsConst.FUNDING_SIGDATE)) { %>
      <tr>
            <td bgcolor="#FFFFFF">
            <trans:showPageMessage label="fundedit.signdate" />:
            </td>
            <td bgcolor="#FFFFFF">
            <%=date_formatter.format(new Date(item.getSignature_date()))%>
            </td>
      </tr>
		<% } %>

      <!-- commitments -->
      <% if (item.getCommitments() != null && item.getCommitments().size() > 0) { %>
      <bean:define id="commitments" name="funding_item" property="commitments" type="java.util.ArrayList"/>
      <tr>
		<td bgcolor="#FFFFFF">
		<trans:showPageMessage label="fundedit.commitments" />:
		</td>
		<td bgcolor="#FFFFFF">
		<logic:iterate id="titem" name="commitments" type="ro.gateway.aida.fnd.FundingTableItem">
		Year:<%=titem.getYear()%>,
		Total: <%=nf.format(titem.getAmount())%><%=titem.getCurrency()%>,
		Date: <%=date_formatter.format(new Date(titem.getDate()))%><br/>
		</logic:iterate>
		</td>
      </tr>
      <% } %>

      <!-- commitments -->
      <% if (item.getDisbursements() != null && item.getDisbursements().size() > 0) { %>
      <bean:define id="disbursements" name="funding_item" property="disbursements" type="java.util.ArrayList"/>
      <tr>
		<td bgcolor="#FFFFFF">
		<trans:showPageMessage label="fundedit.disbursements" />:
		</td>
		<td bgcolor="#FFFFFF">
		<logic:iterate id="titem" name="disbursements" type="ro.gateway.aida.fnd.FundingTableItem">
		Year:<%=titem.getYear()%>,
		Total: <%=nf.format(titem.getAmount())%><%=titem.getCurrency()%>,
		Date: <%=date_formatter.format(new Date(titem.getDate()))%><br/>
		</logic:iterate>
		</td>
      </tr>
      <% } %>

      <% if (item.getComments() != null) { %>
      <tr>
            <td colspan="2" bgcolor="#FFFFFF">
		  <u>Comments:</u><br/>
            <%=item.getComments()%>
            </td>
      </tr>
      <% } %>

      <tr>
            <td colspan="2" bgcolor="#FFFFFF">&nbsp;

            </td>
      </tr>

      <logic:present name="feditable">
      <tr>
            <td colspan="2" class="text_searchbold" bgcolor="#FFFFFF">
            <a onclick="<bean:write name="fitem_edit_js_call" scope="request" />"
                  href="#"
                  style="text-decoration=underline;"><trans:showPageMessage label="fundedit.edititem" /></a> |
            <a onclick="<bean:write name="fitem_delete_js_call" scope="request" />"
                  href="#"
                  style="text-decoration=underline;"><trans:showPageMessage label="fundedit.deleteitem" /></a>
            </td>
      </tr>
      </logic:present>

      </table>
</logic:present>